/*
 * SteepTimer - A timer designed for tea fanatics
 * Copyright (C) 2011  Wesley Crossman
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef CSV_PARSER_H
#define CSV_PARSER_H

#include <QObject>
#include <QStringList>

class CsvParser : public QObject {
public:
    CsvParser(QObject *parent = NULL, bool columnHeaders = true, bool trimSpaces = false, QChar fieldSep = ',');
    void parse(const QString &);
    int columnIndex(const QString &title);
    const QString &cell(QString column, int row);
    const QString &cell(int column, int row);
    const QStringList &row(int row) {return m_data[row];}
    int columnCount(int row) {return m_data[row].size();}
    int rowCount() {return m_data.size();}
private:
    bool m_columnHeaders, m_trimSpaces;
    QList < QStringList > m_data;
    QChar m_fieldSep;
};

#endif
